<!DOCTYPE html>
<html>

<head>
	<title>闲瓜市场 - 我的</title>
	<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
	<link rel="stylesheet" type="text/css" href="{{url_for('static',filename='templates/myinfo.css')}}" />
	<script src="{{url_for('static',filename='js/global.js')}}"></script>
	<script src="{{url_for('static',filename='js/myinfo.js')}}"></script>
</head>

<body onload="onLoad()">
	<nav class="nav">
		<div class="navHerf" id="toFrontPage"><a href="/">首页</a></div>
		<div class="navHerf" id="toLoginPage"><a href="/login">登录</a></div>
		<div class="navHerf" id="toRegPage"><a href="/register">注册</a></div>
		<div class="navHerf" id="toUploadPage"><a href="/upload_new">添加商品</a></div>
		<div class="navUser" id="curUser"><a href="/myinfo">未登录</a></div>
	</nav>
	<div class="main">
		<h1>我的信息</h1>
		<div id="info" class="block">
			<h2 class="title">基本信息</h2>
			<div id="infoDisplay" class="inblockInfo">
				<div id="avatar">
					<img id="avatarImg" src="static/img/default_avatar.jpg">
				</div>
				<div class="name">
					<span class="infoShow" id="infoName">{{info['name']}}</span>
				</div>
				<hr style="margin: 15px 0;">
				<div class="campus">
					<span class="fixedInfo">校区</span>
					<span class="infoShow">{{info['campus']}}</span>
				</div>
				<div class="tel">
					<span class="fixedInfo">电话</span>
					<span class="infoShow">{{info['tel']}}</span>
				</div>
				<div class="vx">
					<span class="fixedInfo">微信号</span>
					<span class="infoShow">{{info['vx']}}</span>
				</div>
				<div class="qq">
					<span class="fixedInfo">QQ号</span>
					<span class="infoShow">{{info['qq']}}</span>
				</div>
				<div class="email">
					<span class="fixedInfo">电子邮箱</span>
					<span class="infoShow">{{info['email']}}</span>
				</div>
				<div class="sid">
					<span class="fixedInfo">学号</span>
					<span class="infoShow">{{info['sid']}}</span>
				</div>
				<div class="aut">
					<span class="fixedInfo">权限</span>
					<span class="infoShow">{{info['aut']}}</span>
				</div>
				<input class="smallOrangeButton" id="modifyInfo" type="button" value="修改" onclick="editInfo()">
			</div>

			<div id="infoEdit" class="inblockInfo">
				<div>
					<span>昵称：</span>
					<input class="infoText" type="text">
				</div>
				<div>
					<span>校区：</span>
					<input class="infoText" type="text">
				</div>
				<div>
					<span>电话：</span>
					<input class="infoText" type="text">
				</div>
				<div>
					<span>微信：</span>
					<input class="infoText" type="text">
				</div>
				<div>
					<span>QQ：</span>
					<input class="infoText" type="text">
				</div>
				<div>
					<span>电子邮箱：</span>
					<input class="infoText" type="text">
				</div>
				<div>
					<span>学号：</span>
					<input class="infoText" type="text">
				</div>
				<div>
					<span>权限：</span>
					<span>{{info['aut']}}</span>
				</div>
				<div id="editInfoButtons">
					<input class="smallOrangeButton" id="confirmInfo" type="button" value="确认"
						onclick="confirmInfo({{info['uid']}})">
					<input class="smallRedButton" id="cancel" type="button" value="取消" onclick="cancelEdit()">
				</div>
			</div>
		</div>

		<div id="uplaod" class="block">
			<h2 class="title">我发布的</h2>
			{% if up|length == 0 %}
			<p>还没有发布商品</p>
			{% endif %}
			<div class="goodsUl">
				<ul>
					{% for u in up %}
					<li class="goodsItem" onclick="window.open('item_{{u['gid']}}')">
						<div>
							<div class="goodsName">{{u['gName']}}</div>
							<div class="goodsPrice">￥{{u['gPrice']}}</div>
							<div class="goodsUpTime">发布时间：{{u['time']}}</div>
						</div>
						<div class="goodsButton">
							<input class="smallOrangeButton" type="button" value="修改"
								onclick="modifyGoods('{{u['gid']}}')">
							<input class="smallRedButton" type="button" value="删除"
								onclick="removeGoods('{{u['gid']}}')">
						</div>
					</li>
					{% endfor %}
				</ul>
			</div>
		</div>

		<div id="deals" class="block">
			<h2 class="title">交易信息</h2>
			{% if deals|length == 0 %}
			<p>还没有交易</p>
			{% endif %}
			<div class="dealUl">
				<ul>
					{% for d in deals %}
					<li class="dealItem">
						<div>
							<span class="dealGoods">{{d['goods_name']}}</span>
						</div>
						<div>
							<span class="sellerName">卖家:{{d['seller_name']}} </span>
							<span class="buyerName">买家:{{d['buyer_name']}}</span>
						</div>
						<div>
							<span class="dealStatus">当前状态:{{d['status']}}</span>
						</div>
						<div>
							<span class="dealTime">交易开始时间:{{d['time']}}</span>
						</div>
						<div class="dealButtons">
							{% if d['buyer_id'] == info['uid'] and d['status'] == '等待卖家回复' %}
							<input type="button" class="smallRedButton" value="放弃购买"
								onclick="modifyDeal('{{d['gid']}}','{{d['buyer_id']}}','{{d['seller_id']}}','remove','')">
							{% endif %}
							{% if d['seller_id'] == info['uid'] and d['status'] == '等待卖家回复' %}
							<input type="button" class="smallRedButton" value="拒绝"
								onclick="modifyDeal('{{d['gid']}}','{{d['buyer_id']}}','{{d['seller_id']}}','remove','')">
							<input type="button" class="smallOrangeButton" value="同意"
								onclick="modifyDeal('{{d['gid']}}','{{d['buyer_id']}}','{{d['seller_id']}}','status','等待交易')">
							{% endif %}
							{% if d['buyer_id'] == info['uid'] and d['status'] == '等待交易' %}
							<input type="button" class="smallOrangeButton" value="确认收货"
								onclick="modifyDeal('{{d['gid']}}','{{d['buyer_id']}}','{{d['seller_id']}}','status','交易完成')">
							{% endif %}
							{% if d['status'] == '交易关闭' %}
							<input type="button" class="smallRedButton" value="删除"
								onclick="modifyDeal('{{d['gid']}}','{{d['buyer_id']}}','{{d['seller_id']}}','remove','')">
							{% endif %}
						</div>
					</li>
					{% endfor %}
				</ul>
			</div>

		</div>

		<div id="favorites" class="block">
			<h2 class="title">收藏</h2>
			{% if fav|length == 0 %}
			<p>还没有收藏商品</p>
			{% endif %}
			<div class="favUl">
				<ul>
					{% for f in fav %}
					<li class="favItem" onclick="window.open('item_{{f['gid']}}')">
						<div>
							<span class="favGoods">{{f['gNmae']}}</span>
							<span class="favSeller">{{f['seller']}}</span>
							<span class="favTime">{{f['fTime']}}</span>
						</div>
						<div class="rmFav">
							<input class="smallRedButton" type="button" value="删除" onclick="removeFavorites('{{info['uid']}}','{{f['gid']}}')">
						</div>
					</li>
					{% endfor %}
				</ul>
			</div>

		</div>

		<input id="logout" value="注销" onclick="logout()"></input>
	</div>
</body>

</html>